package cn.edu.scau.cmi.hekaimin.Hibernate.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils {
	
	
	public static Session getSession() {
		Configuration cfg = new Configuration().configure();
		SessionFactory factory = cfg.buildSessionFactory();
		Session session = factory.openSession();
		session.beginTransaction();
		return session;
	}
	
	public static void colseSession(Session session) {
		if(session != null) {
			session.getTransaction().commit();
			session.close();
		}
	}
}
